package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlCheckUser;
import com.ruoyi.sl.service.ISlCheckUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 复核人Controller
 * 
 * @author admin
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/sl/checkuser")
public class SlCheckUserController extends BaseController
{
    @Autowired
    private ISlCheckUserService slCheckUserService;

    /**
     * 查询复核人列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlCheckUser slCheckUser)
    {
        startPage();
        List<SlCheckUser> list = slCheckUserService.selectSlCheckUserList(slCheckUser);
        return getDataTable(list);
    }

    /**
     * 导出复核人列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:export')")
    @Log(title = "复核人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlCheckUser slCheckUser)
    {
        List<SlCheckUser> list = slCheckUserService.selectSlCheckUserList(slCheckUser);
        ExcelUtil<SlCheckUser> util = new ExcelUtil<SlCheckUser>(SlCheckUser.class);
        util.exportExcel(response, list, "复核人数据");
    }

    /**
     * 获取复核人详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:query')")
    @GetMapping(value = "/{checkId}")
    public AjaxResult getInfo(@PathVariable("checkId") Long checkId)
    {
        return success(slCheckUserService.selectSlCheckUserByCheckId(checkId));
    }

    /**
     * 新增复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:add')")
    @Log(title = "复核人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlCheckUser slCheckUser)
    {
        return toAjax(slCheckUserService.insertSlCheckUser(slCheckUser));
    }

    /**
     * 修改复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:edit')")
    @Log(title = "复核人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlCheckUser slCheckUser)
    {
        return toAjax(slCheckUserService.updateSlCheckUser(slCheckUser));
    }

    /**
     * 删除复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkuser:remove')")
    @Log(title = "复核人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkIds}")
    public AjaxResult remove(@PathVariable Long[] checkIds)
    {
        return toAjax(slCheckUserService.deleteSlCheckUserByCheckIds(checkIds));
    }
}
